package com.ostrich.cloud.ostrichOrderService.component;


import com.ostrich.cloud.ostrichOrderService.infra.model.Order1;
import com.ostrich.cloud.ostrichOrderService.service.service.Order1Service;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@RocketMQMessageListener(consumerGroup = "${rocketmq.consumer.group}", topic = "order")
@Slf4j
public class AsyncListener implements RocketMQListener<Order1> {
    @Resource
    private Order1Service orderService;

    @SneakyThrows
    @Override
    public void onMessage(Order1 order1) {
        log.info("开始进行消费");
        orderService.cancelOrder(order1.getOrderNo());
    }
}
